package org.bangumibuddy.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.bangumibuddy.entity.AnimeEntity;

import java.util.List;

@Mapper
public interface AnimeMapper extends BaseMapper<AnimeEntity> {

    @Select("select * from anime")
    List<AnimeEntity> getAnimeList();

    @Select("select * from anime where id = #{id}")
    AnimeEntity getAnime(Long id);

    @Insert("insert into anime (name, season,seasonNumber, poster) values (#{name}, #{season},#{seasonNumber}, #{poster})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int addAnime(AnimeEntity anima);

    @Select("select * from anime where name = #{name}")
    List<AnimeEntity> getAnimeByName(String name);

    @Select("select * from anime where name = #{name} and seasonNumber = #{seasonNumber}")
    AnimeEntity getAnime(String name,Integer seasonNumber);
}
